<template>
	<view class="content mainpadding">
		<u-navbar safeAreaInsetTop placeholder fixed autoBack>
			<view class="u-nav-slot color_ling text_weight" slot="center">
				資產管理
			</view>
			<view class="u-nav-slot" slot="right" @click="goBindingAccount">
				<text class="color_six text_a">綁定帳戶</text>
			</view>
		</u-navbar>
		<view class="header">
			<view class="total_price text">{{allMoney}}</view>
			<view class=" price_text text">帳戶點數</view>
			<view class="flexbetween mainpadding border_top margin_top">
				<!-- 點擊付款掃碼 -->
				<view class="headerItem" @click="jumpurl('/pages_index/scancode')">付款</view>
				<view class="headerItem" @click="show=true">收款</view>
				<view class="headerItem" @click="goRecharge">儲值</view>
				<view class="headerItem" @click="goWithdrawal">提領</view>
			</view>
		</view>
		<view class="margin_top">
			<view class="color_ling text_weight">點數明細</view>
			<image class="balance_ye" src="/static/images/mine/balance_ye.png" mode=""></image>
		</view>
		<view class="flexcenter" v-if="!list.data.length">
			<view class="placeholderimage" style="margin-top: 100rpx;" ></view>
		</view>
		<view class="margin_top paddinglr ffffff border" v-else>
			<view class="paddingtb border_bottom" v-for="item in list.data" :key="item.id">
				<view class="flexbetween">
					<view class="color_san text_x" style="width: 500rpx;">{{item.memo}}</view>
					<view class="price">{{item.money}}</view>
				</view>
				<view class="color_jiu text_b margin_top1">{{http.timereturn(item.createtime * 1000)}}</view>
			</view>
		</view>
		<u-popup :show="show" mode="center" :round="15" @close="show=false">
			<view class="popupBox text">
				<image class="headerImg" src="/static/images/mine/paymentHeader.png" mode=""></image>
				<view class="color_ling text_five">{{userInfo.nickname}}</view>
				<view class="flexcenter margin_top2">
					<uqrcode ref="uqrcode" canvas-id="qrcode" v-bind:value="qrcodeurl_text"
						:options="{ margin: 10}" size="180">
					</uqrcode>
				</view>
				<view class="color_jiu text_g margin_top">長按保存到手機</view>
			</view>
		</u-popup>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				show: false,
				list: {
					data: []
				},
				allMoney:"",
				userInfo:{},
				qrcodeurl_text:""
			}
		},
		onShow(){
			this.getInfo()
			this.getlist()
			this.getfkurl()
		},
		methods: {
			getfkurl() {
				this.http.request("/api/member/getfukuan", 'POST', {}).then(res => {
					this.qrcodeurl_text = res.data + "?id=" + uni.getStorageSync("user_id")
				})
			},
			jumpurl(url){
				if(!this.userInfo.paypass){
					this.http.toast("請設置支付密碼")
					setTimeout(()=>{
						uni.navigateTo({
							url:"/pages_mine/setpassword"
						})
					},1000)
					return false
				}
				uni.redirectTo({
					url
				})
			},
			
			async getInfo() {
				let res = await this.http.request('/api/member/userInfo', 'GET', {})
				this.userInfo = res.data
			},
			getlist() { //獲取個人信息
				let _this = this
				let url = "/api/member/zcgl"
				this.http.request(url, 'POST', {}).then(res => {
					this.list.data = res.data.list
					this.allMoney = res.data.money
				})
			},
			goBindingAccount(){ //綁定帳戶
				uni.navigateTo({
					url:"./bindingAccount"
				})
			},
			goRecharge(){ //儲值
				uni.navigateTo({
					url:"./recharge"
				})
			},
			goWithdrawal(){ //提領
				uni.navigateTo({
					url:"./withdrawal"
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.header {
		height: 391rpx;
		background-image: url("/static/images/mine/balance_bg.png");
		background-size: 100% 100%;
		padding-top: 80rpx;
		box-sizing: border-box;

		.total_price {
			font-size: 80rpx;
			font-family: DIN Next LT Pro-Bold, DIN Next LT Pro;
			font-weight: bold;
			color: #360C00;
		}

		.price_text {
			font-size: 36rpx;
			font-family: PingFang SC-Medium, PingFang SC;
			font-weight: 500;
			color: #74580E;
		}

		.border_top {
			border-top: 1rpx solid rgba(255, 255, 255, 0.3);
		}

		.headerItem {
			width: 144rpx;
			height: 65rpx;
			text-align: center;
			line-height: 65rpx;
			border: 2rpx solid rgba(255, 255, 255, 1);
			border-radius: 10rpx;
			font-size: 28rpx;
			font-family: PingFang SC-Medium, PingFang SC;
			font-weight: 500;
			color: #360C00;
		}
	}

	.balance_ye {
		width: 127rpx;
		height: 10rpx;
		display: block;
		margin-top: -10rpx;
	}

	.border_bottom {
		border-top: 1rpx solid rgba(0, 0, 0, 0.03);
	}

	.price {
		font-size: 32rpx;
		font-family: DIN Next LT Pro-Bold, DIN Next LT Pro;
		font-weight: bold;
		color: #FFB800;
	}

	.popupBox {
		padding-bottom: 50rpx;
		.headerImg {
			width: 658rpx;
			height: 237rpx;
		}

		.codeImg {
			width: 433rpx;
			height: 433rpx;
		}
	}
</style>